package com.by.controller;

import com.by.remote.api.StockRemoteClient;
import com.by.remote.dto.StockDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @version 1.0
 * @Author 彭彦彬
 * @Date 2025/4/2 19:22
 * @注释
 */
@RestController
public class GoodsController {
    @Autowired
    private StockRemoteClient stockRemoteClient;

    @GetMapping("/goods")
    public Map getGoods(@RequestParam("id") int id) {
        Map map = new HashMap();
        Map query = stockRemoteClient.query(id);
        map.put("name", "加多宝");
        map.put("type", "凉茶");
        map.put("stock", map);
        return query;
    }

    @PostMapping("/goodsByLike")
    public Map getGoodLike(@RequestBody StockDto stockDto) {
        return stockRemoteClient.selectByLike(stockDto);
    }
}
